
//解码decodeURIComponent
let userInfo = getCookie('userInfo') ? JSON.parse(decodeURIComponent(getCookie('userInfo'))) : null;
if (userInfo) {
    // 登录状态
    document.querySelector('.resgist').innerHTML = `${userInfo.nickname} 欢迎`
    //退出按钮
    document.querySelector('.out').addEventListener('click', () => {
        //删除cookie
        removeCookie('userInfo');
        //重新加载
        location.reload();
    })
} else {
    document.querySelector('.resgist').innerHTML = '<a href="login.html">登录</a>'
}

axios.get(
    'http://39.98.112.34:8000/hotel/index'
)
    .then((res) => {
        let response = res.data.data
        console.log(res.data.data);
        let html = '';
        response.forEach(function (item,i) {
            html += `
                <a href = 'hotaldes.html?id=${item.id}'>
                    <div class='box1'>
                    <div class="left">${i+1}</div>
                    <div class="center">
                        <h3>${item.name}</h3>
                        <p>${item.districtName}</p>
                        <p>
                            <span>4.7超棒</span>
                            <span>￥${item.priceStart}</span>
                        </p>
                    </div>
                    <div class="right"><img src="${item.photos}" alt="" ></div>
                    <div class="detail">
                    ${item.content}
                    </div>
                </div>
                </a>
                `
        });
        document.querySelector('.hotal').innerHTML = html;
    })